import { _decorator, Button, Component, Label, ProgressBar, View ,Node, EventTouch, Vec2, v2, UITransform, v3} from "cc";
import BaseView from "../../../framework/ui/BaseView";
import { gameData } from "../../data/GameData";
import { bindNode, SearchType, uiview } from "../../../framework/ui/UIDecorator";
import { LogMgr } from "../../../framework/log/LogMgr";
import { BattleRoom } from "../../funcs/battle/BattleRoom";
import { Joystick } from "../components/Joystick";
import { GlobalEventMgr } from "../../../framework/event/GlobalEventMgr";
import { GlobalEventTyp } from "../../GlobalEventTyp";

const { ccclass ,property} = _decorator;


@ccclass("BattleView")
export class BattleView extends BaseView{

    //============等级进度===============
    @bindNode("level_bar",ProgressBar)
    levelBar:ProgressBar
    @bindNode("level_bar/level",Label)
    levelText:Label


    // //============遥感===============
    // @bindNode("Joystick",Joystick)
    // joystickNode:Joystick


    //============重新开始===============
    @bindNode("startNew",Button)
    startNew:Button

    protected init(): void {
        this.useAnimation = false
        GlobalEventMgr.ins.addNotice(GlobalEventTyp.BattleStarted,this,this.onBattleStated)
        GlobalEventMgr.ins.addNotice(GlobalEventTyp.BattleEnd,this,this.onBattleEnd)
    }

    protected show(...args: any[]): void {
        this.startNew.node.on(Button.EventType.CLICK,async ()=>{
            GlobalEventMgr.ins.emit(GlobalEventTyp.BattleStart,true)
        })


    }

    protected close(): void {
        this.startNew.node.off(Button.EventType.CLICK)
        // this.joystickNode.unwork()
    }

    onBattleStated(){
        // this.joystickNode.work()
    }
    onBattleEnd(){
        // this.joystickNode.unwork()
    }
}